<?php
	echo validation_errors();
	echo form_open('teacher/create_schedule');
?>
<h1>Schedule</h1>

<table>
<tr><td>Date</td><td>Time</td><td>Student</td><td>Subject</td><td>Admin status</td></tr>
<?php
	$userid = $this->session->userdata("userid");
	$constraints = array(
	                     "teacherid" => $userid
	                     );
	
	$query = $this->db->get_where("schedule", $constraints);
	
	foreach($query->result() as $row){
		echo "<tr>";
		$student_name = $this->db->get_where("students", array("userid" => $row->studentid));
		$name = "";
		
		foreach($student_name->result() as $sn){
			$name = $sn->lastname . ", " . $sn->firstname;
		}
		
		$subject_name = $this->db->get_where("subjects", array("subjectid" => $row->subjectid));
		$sname = "";
		
		foreach($subject_name->result() as $subname){
			$sname = $subname->subjectname;
		}
		
		echo "<td>" . $row->date . "</td><td>" . $row->time . "</td><td>" . $name . "</td><td>" . $sname . "</td><td>".
		     $row->adminstatus . "</td>";
		echo "</tr>";
	}
?>
</table>

Date:<br/>
<select id="years" name="y">
</select>
	
<select id="months" name="m" onchange="showDates()">
</select>

<select id="dates" name="d">
</select>

<script type="text/javascript" language="javascript" src="/165-project/public/js/birthday.js"></script>

<br />
Time:<br />
<input type="text" name="time" /><br />

Subject:<br />
<?php
	$query = $this->db->get("subjects");
	
	foreach($query->result() as $row){
		$subjectid = $row->subjectid;
		echo "<input type='radio' value='" . $subjectid . "' id='" . $subjectid . "' name='subject' /> " .
		     "<label for='" . $subjectid . "'>" . $row->subjectname  . "</label><br />\n";
	}
?>

<?php echo form_submit('save', "Save"); ?>
